<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:f="http://java.sun.com/jsf/core" xmlns:c="http://java.sun.com/jsp/jstl/core">
    <script type="text/javascript">  
function takeMyValue(val,id) {  
   // alert(val.value);
 document.getElementById("mainForm:DMProjectPropValueHidden").value=val.value;
 document.getElementById("mainForm:DMProjectPropValueIDHidden").value=id;
 remoteCMD1();
}  
    </script> 
    <h:inputHidden id="DMProjectPropValueHidden" value="#{generateWizardBean.updateDmPrjPropTable.value}"/>
    <h:inputHidden id="DMProjectPropValueIDHidden" value="#{generateWizardBean.updateDmPrjPropTable.ID}"/>


    <p:remoteCommand name="remoteCMD1" action="#{generateWizardBean.updatePrjPropVal}" 
                     process="@this,DMProjectPropValueHidden,DMProjectPropValueIDHidden" update="list_growl,step2MSG"/>

    <p:messages id="step2MSG" showDetail="true" />
    <p:panel header="Project">

        
        <h:outputText value="#{generateWizardBean.selectedMainProjectTable.ID}"/>
        <h:panelGrid columns="2" columnClasses="label, value">
            <h:selectOneListbox size="5"  id="dataModelProject_IDTxt"
                                value="#{generateWizardBean.selectedDataModelProjectTable.ID}"
                                 required="false"
                                 rendered="true"
                                 requiredMessage="dataModelProject is Mandatory" onchange="remoteCMDRefresh();">
                <f:selectItems value="#{generateWizardBean.dataModelProjectList}" />
            </h:selectOneListbox>

        </h:panelGrid>
        <p:commandButton value="New" id="new_project" oncomplete="add_prj_dm_dialog.show()"/>
        <p:commandButton value="Edit" id="edit_project" oncomplete="varaddNewProjectDialog.show()"/>
        <p:remoteCommand name="remoteCMDRefresh" action="#{generateWizardBean.refreshProjectProperties}" process="@this, dataModelProject_IDTxt" update="@this,dt1,dm_prj_msg"/>

    </p:panel>

    <p:dataTable id="dt1" var="info" value="#{generateWizardBean.dmPrjPropTables}">

        <p:column>
            <f:facet name="header">
                <h:outputText value="Code" />
            </f:facet>
            <h:outputText title="#{info.prjPropCode}" value="#{info.prjPropCode}" />

        </p:column>
        <p:column>
            <f:facet name="header">
                <h:outputText value="INPUT" />
            </f:facet>
            
                <h:inputText rendered="#{info.prjPropType == 'inputtext'}" value="#{info.value}" id="inputTxt12" onblur="takeMyValue(this,#{info.ID});" />
                <h:selectOneRadio rendered="#{info.prjPropType == 'truefalse'}" value="#{info.value}" id="inputRadioBx12" onchange="takeMyValue(this,#{info.ID});" >
                    <f:selectItem itemLabel="true" itemValue="true"/>
                    <f:selectItem itemLabel="false" itemValue="false"/>
                </h:selectOneRadio>
        </p:column>

        <p:column rendered="false">
            <f:facet name="header">
                <h:outputText value="Value" />
            </f:facet>
            <p:commandButton id="preparetoupdateCMD" process="@this" image="ui-icon ui-icon-plusthick" title="update" action="#{generateWizardBean.prepareToUpdate}"  update="dmProject,list_growl,mainForm"  oncomplete="showUpdateDialog();" >
                <f:param name="dmPrjPropIDparm" value="#{info.ID}" />
            </p:commandButton>
        </p:column>

    </p:dataTable>
    <p:remoteCommand name="showUpdateDialog" oncomplete="varUpdateProjectDialog.show()" process="@this" update="@this,update_dm_prj_prp_dialog"/>
    <p:remoteCommand name="refreshDT" process="@this"  update="dt1,list_growl,dm_prj_msg"/>

    <p:dialog id="update_dm_prj_prp_dialog"  header="Update data model prop" widgetVar="varUpdateProjectDialog"
              modal="true" draggable="false" showEffect="fade" width="500" height="300" closeOnEscape="false">

        <table>

            <tr>
                <td>    <h:outputLabel rendered="true" value="Value" /></td>
            <td>:</td>
            <td>
            <h:inputText  id="update_dm_prj_val_Txt"
                          value="#{generateWizardBean.dmPrjPropTable.value}"
                          required="false"
                          rendered="true"
                          requiredMessage="value is Mandatory"/>
            </td>
            </tr>


        </table>

        <h:panelGrid id="displayUpdatePanelGrid" >
            <p:commandButton process="@this,update_dm_prj_val_Txt"
                             value="update" title="Update DmAttrProp" action="#{generateWizardBean.updateProjectProps}" oncomplete="varUpdateProjectDialog.hide();refreshDT();"  />
        </h:panelGrid>
    </p:dialog>


    <p:dialog id="add_prj_dm_dialog"  header="Add New Data Model Project" widgetVar="add_prj_dm_dialog"
              modal="true" draggable="false" showEffect="fade" width="500" height="300" closeOnEscape="false">
                <h:outputText value="#{generateWizardBean.selectedMainProjectTable.ID}"/>

        <table>

            <tr>
                <td>    <h:outputLabel rendered="true" value="Value" /></td>
            <td>:</td>
            <td>
            <h:inputText  id="ins_dataModelProject_Txt"
                          value="#{generateWizardBean.insertDataModelProjectTable.code}"
                          required="false"
                          rendered="true"
                          requiredMessage="Project Name is Mandatory"/>
            </td>
            </tr>


        </table>

        <h:panelGrid >
            <p:commandButton process="@this,ins_dataModelProject_Txt" update="dataModelProject_IDTxt"
                             value="update" title="Update DmAttrProp" action="#{generateWizardBean.addNewDMProject}" oncomplete="add_prj_dm_dialog.hide();refreshDT();"  />
        </h:panelGrid>
    </p:dialog>

</html>